package com.qc.toutiao.util;

import java.io.IOException;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class SessionUtil {
	
	public SqlSession getSession(){
		SqlSession session=null;
		try {
			SqlSessionFactory sf=new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("mybatis.xml"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		return session;
	}
	public void close(SqlSession session){
		if(session !=null){
			session.commit();
			session.close();
		}
	}
}
